#import <3Dreality_api.h>
#import "DebugMethods.h"
#import "DebuggingExtensions.h"

@implementation Camera (Camera_ResponderMethods)
- dbg_dumpShapeHierarchy:sender
{
    id currentCamera=[Camera currentCamera];
    id shape = [currentCamera selectedShape];
    [currentCamera dumpHierarchyFrom:shape atDepth:[shape shapeDepth]];
    return self;
}

- dbg_dumpWorldHierarchy:sender
{
    id currentCamera=[Camera currentCamera];
    [currentCamera dumpHierarchyFromWorldShape];
    return self;
}
@end

@implementation Camera (debug_methods)
void spaces(int d)
{
    int i;
    for(i=0;i<d;i++)
	fprintf(stderr, "  ");
}
- dumpHierarchyFrom:shape atDepth:(int) d
{
    id s = shape;

    spaces(d);
    fprintf(stderr, "%s\n", [shape shapeName]);

    if([s descendant])
	[self dumpHierarchyFrom:[s descendant] atDepth:d+1];
    if([s nextPeer])
	[self dumpHierarchyFrom:[s nextPeer] atDepth:d];
    
    return self;
}

- dumpHierarchyFromWorldShape
{
    [self dumpHierarchyFrom:[self worldShape] atDepth:0];
    return self;
}
@end
